
export function deepClone<T = any>(origin: any, target: any): T {
    var target = target || {};
    for (var prop in target) {
        if (target.hasOwnProperty(prop)) {
            if (target[prop] !== null && typeof target[prop] === 'object') {
                origin[prop] = Object.prototype.toString.call(target[prop]) === '[object Array]' ? [] : {};
                deepClone(origin[prop], target[prop]);
            } else {
                origin[prop] = target[prop];
            }
        }
    }
    return origin;
}
export function clone(obj: any) {
    let type = Object.prototype.toString.call(obj);
    if( type == '[object Boolean]' || type == '[object Undefined]' || type == '[object Null]'
        || type == '[object String]' || type == '[object Number]' || type == '[object Function]'
    ) {
        return obj;
    }
    if(type == '[object Array]') {
        let arr: any[] = [];
        return deepClone(arr, obj);
    }
    if(type == '[object Object]') {
        return deepClone({}, obj);
    }
    console.warn('unexpect clone!');
    return obj;
}
